Hello and welcome to
this demonstration on reading and writing the
data in an Excel file. In this video, you will learn to create a workflow that compares the first two columns
of Excel and displays the third columns result
using Excel activities. So let's begin. Start with creating
an Excel file. Open a new Excel file and
create two columns, A and B. Enter 10 random numbers between
1 and 100 in each column. Save and close the file. Go to UiPath Studio, search for an Excel
Application Scope activity, and drag and drop in
the Designer panel. Rename the sequence as Excel Automation and add
an annotation to it. Rename the Excel
Application Scope activity as comparison.xlsx. Click the folder icon and select the Excel file that was just created. Click "Open". Search for a Read Range activity under the Excel category in the Activities panel
and drag and drop it in the Do container of the Excel
Application Scope activity. Rename it. Navigate to the Properties panel of
the Read Range activity. In the DataTable property, press "Control" plus
"K" to create a new variable and name
it as dt_dummyData. Now, search for an Add
Data Column activity in the Activities panel
and drag and drop it below the Read Range
activity and rename it. Go to the Properties panel. In the ColumnName property, enter comparison
in double qoutes and enter the
variable dt_dummyData in the DataTable property. Search for a For Each Row
in Data Table activity in the Activities panel
and drag and drop it below the Add Data Column
activity and rename it. In the VB expression text box, enter the variable dt_dummyData. Search for an if activity
in the Activities panel. Drag and drop it in
the body section of the For Each Row in Data Table activity
and rename it. In the condition box, enter CInt followed by
CurrentRow 0 in parenthesis. Ensure additional
parenthesis around zero, then a greater than symbol. After that, enter CInt
followed by CurrentRow 1. Ensure additional
parenthesis around one. Here CInt function converts the string value to an integer. The whole conditions check
whether the values in the first column are
greater than the second in the Excel file. Search for an Assign activity
and drag and drop it in the then section of the
if activity. Rename it. In the first text box, enter CurrentRow then
two in parenthesis. In the adjacent text box, enter the text Greater
in double quotes. Click "Show Else" to view the else section of
the if activity. Drag and drop another
if activity in the else section of
the first if activity. Rename it. In the condition box, enter CInt followed by
CurrentRow 0 in parenthesis. Ensure additional
parenthesis around zero, then enter less than symbol. After that, enter CInt
followed by Current Row 1. Ensure additional
parenthesis around one. Here CInt function converts the string value to an integer, and the whole conditions
check whether the values in the first column are
smaller than the second in the Excel file. Search for an Assign
activity and drag and drop it into then section of the
if activity. Rename it. In the first text box, enter CurrentRow then
two inside parenthesis. In the adjacent box, enter the text Lesser
in double quotes. Click "Show Else" to view the else section of
the if activity. Drag and drop and
Assign activity in the else section of the if
activity and rename it. In the first text box, enter CurrentRow then
two inside parenthesis, and in the adjacent box, enter the text Equal
in double quotes. Now, search for a
Write Range activity under the Excel category in the Activities
panel and drag and drop it below the For Each
Row in Data Table activity. Rename it. In the
first text box, enter Sheet2 in double quotes. In the second text box, delete the existing expression
and enter double quotes. In the third text box, enter the variable dt_dummyData. Navigate to the
Properties panel of the Write Range activity and
check the AddHeaders option. This activity will insert
the result in a new sheet called Sheet2 in the
same Excel file. Save the project and run it. Now, open the Excel file
to check the outcome. Each rows result is stored in the third column in a new sheet. It is encouraged to
create the workflow as demonstrated and
try this activity. Thank you for watching.